<template>
    <div >
        <el-form ref="form" :model="form" label-width="80px" style="margin-right: 50px">
        <el-form-item label="姓名">
            <el-input v-model="form.trueName" style="width: 150px"></el-input>
        </el-form-item>

        <el-form-item label="科室">
            <el-select v-model="form.department_id" placeholder="请选择科室">
                <el-option v-for="d in DepartmentData" :key="d.did" :value="d.did" :label="d.departmentName"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="级别">
            <el-select v-model="form.type" placeholder="请选择级别" >
                <el-option v-for="t in titleData" :key="t.id" :value="t.id" :label="t.title"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="手机号">
            <el-input v-model="form.phone" placeholder="请输入手机号" style="width:350px"></el-input>
        </el-form-item>
            <el-form-item label="邮箱">
                <el-input v-model="form.mailbox" style="width:350px"></el-input>
            </el-form-item>
        <el-form-item label="年龄">
            <el-input v-model="form.age" style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">确认</el-button>
        </el-form-item>
    </el-form></div>
</template>

<script>
    import DoctorAuthority from '../../model/ww/DoctorAuthority'
    const  doctorAuthority=DoctorAuthority.getInstance();
    export default {
        name: "DoctorCU",
        data(){
            return {
                form: {},
                titleData:[], //所有角色
                DepartmentData:[], //所有科室
            }
        },
        props:['upstatus']
        ,
        methods: {
            list(){
                doctorAuthority.getTitle().then((response)=>{
                    this.titleData=response.data.data
                })
                doctorAuthority.getDepartment().then((response)=>{
                    this.DepartmentData=response.data.data.data
                })
            },
            onSubmit() {
                if(this.upstatus==undefined){
                    doctorAuthority.save(this.form).then(()=>{
                        this.$message("添加成功")
                        this.$emit("close",123111)
                    })
                }else{
                   this.upstatus
                    this.$message("修改")
                }

            },

        },
        created() {
            this.list();
            console.log(this.upstatus)
        }
    }
</script>

<style scoped>

</style>